<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    :close-on-click-modal="false"
    append-to-body
    title="处方详情"
    center
  >
    <el-table :data="selectMechie" border height="320px" highlight-current-row>
      <el-table-column
        prop="name"
        label="药品名称及规格"
        align="center"
        width="140px"
      >
        <template slot-scope="scope">
          {{ scope.row.name + "(" + scope.row.size + ")" }}
        </template>
      </el-table-column>
      <el-table-column
        prop="dosage"
        label="剂量"
        align="center"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.dosage  + scope.row.dosageUnit }}
        </template>
      </el-table-column>
      <el-table-column
        v-if="DrugClassCode == '中药'"
        prop="decocting"
        label="煎煮法"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        v-if="DrugClassCode != '003'"
        prop="usage"
        label="用法"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        v-if="DrugClassCode != '003'"
        prop="frequency"
        label="频次"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        v-if="DrugClassCode != '003'"
        prop="days"
        label="天数(天)"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        v-if="DrugClassCode != '003'"
        prop="num"
        label="数量"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        v-if="DrugClassCode != '003'"
        prop="price"
        label="单价(元)"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        prop="unit"
        label="单位"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="remark"
        label="备注"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        label="总金额(元)"
        v-if="DrugClassCode != '003'"
        align="center"
        width="90px"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{
            !(scope.row.price * scope.row.num)
              ? ""
              : scope.row.price * scope.row.num
          }}
        </template>
      </el-table-column>
    </el-table>
    <div slot="footer">
      <el-button @click="handleClose" type="primary">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      selectMechie: [],
      DrugClassCode: null,
    };
  },
  methods: {
    show(row) {
      this.selectMechie = JSON.parse(row.medical);
      this.DrugClassCode = JSON.parse(row.medical)[0].DrugClassCode;
      this.dialogVisible = true;
    },
    handleClose() {
      this.dialogVisible = false;
    },
  },
};
</script>

<style>
</style>